<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Navo Portable Library: navo/algorithm/nonlinear/binary/treaplnk.h源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Navo Portable Library&#160;<span id="projectnumber">Ver 1.0.20120827</span></div>
   <div id="projectbrief">Provides generic platform independent facilities.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>数据结构</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>全局定义</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>navo/algorithm/nonlinear/binary/treaplnk.h</h1>  </div>
</div>
<div class="contents">
<a href="treaplnk_8h.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* #ifdef _MSC_VER */</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef __NV_TREAPLNK__</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define __NV_TREAPLNK__</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="cdef_8h.html" title="Definitions and declarations for common constants, types, variables.">../../../port/cdef.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="integer_8h.html" title="Provides standard integer types.">../../../port/integer.h</a>&quot;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00023"></a>00023 <span class="preprocessor">#endif  </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00024"></a>00024 
<a name="l00039"></a><a class="code" href="struct____treaplnk__node.html">00039</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct____treaplnk__node.html" title="树堆节点">__treaplnk_node</a> {
<a name="l00041"></a><a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d">00041</a>     <span class="keyword">struct </span><a class="code" href="struct____treaplnk__node.html" title="树堆节点">__treaplnk_node</a>* <a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d" title="父节点">parent</a>;
<a name="l00043"></a><a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906">00043</a>     <span class="keyword">struct </span><a class="code" href="struct____treaplnk__node.html" title="树堆节点">__treaplnk_node</a>* <a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a>;
<a name="l00045"></a><a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c">00045</a>     <span class="keyword">struct </span><a class="code" href="struct____treaplnk__node.html" title="树堆节点">__treaplnk_node</a>* <a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a>;
<a name="l00047"></a><a class="code" href="struct____treaplnk__node.html#a12a507bc765598b5db4100af52f045e3">00047</a>     <span class="keywordtype">size_t</span> <a class="code" href="struct____treaplnk__node.html#a12a507bc765598b5db4100af52f045e3" title="优先权">priority</a>;
<a name="l00048"></a>00048 }<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaf6b43fa9ed65d27786f3d63b27d5b783" title="节点">treaplnk_node</a>, *<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4b4308fba0d58f5079b69ba269bacb01" title="迭代器">treaplnk_iter</a>;
<a name="l00049"></a>00049 
<a name="l00054"></a><a class="code" href="structtreaplnk__root.html">00054</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00056"></a><a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed">00056</a>     <a class="code" href="struct____treaplnk__node.html" title="树堆节点">treaplnk_node</a>* <a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>;
<a name="l00057"></a>00057 }<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>;
<a name="l00058"></a>00058 
<a name="l00063"></a><a class="code" href="structtreaplnk__info.html">00063</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00065"></a><a class="code" href="structtreaplnk__info.html#a76d971a3c552bc58ba9f0d5fceae9806">00065</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtreaplnk__info.html#a76d971a3c552bc58ba9f0d5fceae9806" title="节点数">count</a>;
<a name="l00067"></a><a class="code" href="structtreaplnk__info.html#a820c167ceaaa9759b0ca2695d22db55c">00067</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtreaplnk__info.html#a820c167ceaaa9759b0ca2695d22db55c" title="深度">depth</a>;
<a name="l00069"></a><a class="code" href="structtreaplnk__info.html#a62f3b2ad4f6c6147d1bb9a71dd8c9656">00069</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtreaplnk__info.html#a62f3b2ad4f6c6147d1bb9a71dd8c9656" title="叶子数">leafs</a>;
<a name="l00070"></a>00070 }<a class="code" href="structtreaplnk__info.html" title="树信息表">treaplnk_info</a>;
<a name="l00071"></a>00071 
<a name="l00083"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae43b34feae059ffecefd491a89bc7f09">00083</a> <span class="preprocessor">#define TREAPLNK_ROOT(name) treaplnk_root name = {NULL}</span>
<a name="l00084"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4ab24c4e62e36e89e27f8d7a4fa3149b">00084</a> <span class="preprocessor"></span><span class="preprocessor">#define TREAPLNK_NODE(name) treaplnk_node name = {NULL, NULL, NULL, 0}</span>
<a name="l00085"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga7d3bd03455d4ac4b07695da1561ac52d">00085</a> <span class="preprocessor"></span><span class="preprocessor">#define TREAPLNK_INFO(name) treaplnk_info name = {0, 0, 0}</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00093"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12473c60d17919848883f04bfa09a5a5">00093</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12473c60d17919848883f04bfa09a5a5" title="单参数回调函数指针">treaplnk_pr1</a>)(<a class="code" href="struct____treaplnk__node.html" title="树堆节点">treaplnk_node</a>*);
<a name="l00094"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaafa3ea646d74cd8a0b8bb71ab2b727d7">00094</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaafa3ea646d74cd8a0b8bb71ab2b727d7" title="双参数回调函数指针">treaplnk_pr2</a>)(<a class="code" href="struct____treaplnk__node.html" title="树堆节点">treaplnk_node</a>*, treaplnk_node*);
<a name="l00095"></a>00095 
<a name="l00103"></a>00103 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad66cce0995090f8ff4e255e45d83e927" title="获取树的节点总数">treaplnk_count</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root);
<a name="l00104"></a>00104 
<a name="l00113"></a>00113 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4dbe3b5512bf8d6407cef0ff821d316c" title="计算两个节点的迭代距离">treaplnk_distance</a>(treaplnk_iter first, treaplnk_iter last);
<a name="l00114"></a>00114 
<a name="l00123"></a>00123 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga45104dc4d6a3c99f0ca6adb26a1ba60b" title="计算迭代器的正向索引">treaplnk_index_of</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_iter itr);
<a name="l00124"></a>00124 
<a name="l00133"></a>00133 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae3d748d30e5da2583bb3bc3b12ca68db" title="计算迭代器的逆向索引">treaplnk_reverse_index_of</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_iter itr);
<a name="l00134"></a>00134 
<a name="l00142"></a>00142 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga69bd6cd659eb01cee33b211cc5883fab" title="计算树的深度">treaplnk_depth</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root);
<a name="l00143"></a>00143 
<a name="l00151"></a>00151 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0e528fc27a6476cf7cac10305a4bc191" title="计算树的叶子数">treaplnk_leafs</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root);
<a name="l00152"></a>00152 
<a name="l00160"></a>00160 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gac1c3d37dd05e4d469eff62eebc4bb483" title="获取树的信息，包括节点数、深度、叶子数">treaplnk_get_info</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, <a class="code" href="structtreaplnk__info.html" title="树信息表">treaplnk_info</a>* info);
<a name="l00161"></a>00161 
<a name="l00205"></a>00205 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaae88f9f0194b5721af46c65d5dea2078" title="修正树">treaplnk_fix</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_node* node, 
<a name="l00206"></a>00206                          treaplnk_node* parent);
<a name="l00207"></a>00207 
<a name="l00214"></a>00214 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafdefc8690af7387b1f376247e69b9ad7" title="移除某个节点">treaplnk_erase</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_node* entry);
<a name="l00215"></a>00215 
<a name="l00229"></a>00229 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0157ffea5e9b1a9d9bd903d8c6a518d8" title="移除区域内的节点">treaplnk_erases</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_iter begin, 
<a name="l00230"></a>00230                             treaplnk_iter end, <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12473c60d17919848883f04bfa09a5a5" title="单参数回调函数指针">treaplnk_pr1</a> erase_handler);
<a name="l00231"></a>00231 
<a name="l00243"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gac7e32a548f651a2b676985202b54e661">00243</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gac7e32a548f651a2b676985202b54e661" title="初始化树根">treaplnk_init</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00244"></a>00244 {
<a name="l00245"></a>00245     root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a> = NULL;
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247 
<a name="l00262"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga96e53af6fe7142244a05e80bce0b3eb0">00262</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga96e53af6fe7142244a05e80bce0b3eb0" title="判断树是否为空">treaplnk_empty</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264     <span class="keywordflow">return</span> !root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>;
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 
<a name="l00267"></a>00267 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __treaplnk_singular(treaplnk_node* root)
<a name="l00268"></a>00268 {
<a name="l00269"></a>00269     <span class="keywordflow">return</span> root &amp;&amp; !root-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a> &amp;&amp; !root-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a>;
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271 
<a name="l00286"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad66345b9a303383b3df2c5028d86f1f9">00286</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad66345b9a303383b3df2c5028d86f1f9" title="判断树是否只有单个节点">treaplnk_singular</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288     <span class="keywordflow">return</span> __treaplnk_singular(root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>);
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290 
<a name="l00320"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0633509d7f4416a090815f50a95a7a63">00320</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0633509d7f4416a090815f50a95a7a63" title="判断树是否可以序列化">treaplnk_serialable</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00321"></a>00321 {
<a name="l00322"></a>00322     <span class="keywordflow">return</span> !!root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>;
<a name="l00323"></a>00323 }
<a name="l00324"></a>00324 
<a name="l00332"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga358134910aadd9d7580dbf0fed03bc31">00332</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga358134910aadd9d7580dbf0fed03bc31" title="得到左子节点">treaplnk_left</a>(treaplnk_node* node)
<a name="l00333"></a>00333 {
<a name="l00334"></a>00334     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a>;
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336 
<a name="l00344"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga055771881b33a6f1b5c69c8fd0177c1e">00344</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga055771881b33a6f1b5c69c8fd0177c1e" title="得到右子节点">treaplnk_right</a>(treaplnk_node* node)
<a name="l00345"></a>00345 {
<a name="l00346"></a>00346     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a>;
<a name="l00347"></a>00347 }
<a name="l00348"></a>00348 
<a name="l00355"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4f501b5392c966d7f7ccb6253ec465">00355</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4f501b5392c966d7f7ccb6253ec465" title="得到父节点">treaplnk_parent</a>(treaplnk_node* node)
<a name="l00356"></a>00356 {
<a name="l00357"></a>00357     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d" title="父节点">parent</a>;
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359 
<a name="l00366"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga1f4ff7046c020cd7a83d88fc43f4da18">00366</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga1f4ff7046c020cd7a83d88fc43f4da18" title="得到节点的优先权">treaplnk_priority</a>(treaplnk_node* node)
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____treaplnk__node.html#a12a507bc765598b5db4100af52f045e3" title="优先权">priority</a>;
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370 
<a name="l00379"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaeb5c0d6ab3522c1816b6834675be2828">00379</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaeb5c0d6ab3522c1816b6834675be2828" title="判断当前节点是否是根节点">treaplnk_is_root</a>(treaplnk_iter itr)
<a name="l00380"></a>00380 {
<a name="l00381"></a>00381     <span class="keywordflow">return</span> !<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4f501b5392c966d7f7ccb6253ec465" title="得到父节点">treaplnk_parent</a>(itr);
<a name="l00382"></a>00382 }
<a name="l00383"></a>00383 
<a name="l00392"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae0ca77682f8559c79d5dc71bbc07756e">00392</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae0ca77682f8559c79d5dc71bbc07756e" title="判断当前节点是否是叶子节点">treaplnk_is_leaf</a>(treaplnk_iter itr)
<a name="l00393"></a>00393 {
<a name="l00394"></a>00394     <span class="keywordflow">return</span> !itr-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a> &amp;&amp; !itr-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a>;
<a name="l00395"></a>00395 }
<a name="l00396"></a>00396 
<a name="l00408"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga33f96e3db43b13c620d9ecf47be03418">00408</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga33f96e3db43b13c620d9ecf47be03418" title="链接两个节点">treaplnk_link</a>(treaplnk_iter newly, treaplnk_iter parent, 
<a name="l00409"></a>00409                                  treaplnk_iter* plink)
<a name="l00410"></a>00410 {
<a name="l00411"></a>00411     <span class="comment">/* 简单地将newly节点链接到parent节点下 */</span>
<a name="l00412"></a>00412     *plink = newly;
<a name="l00413"></a>00413     newly-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a> = NULL;
<a name="l00414"></a>00414     newly-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a> = NULL;
<a name="l00415"></a>00415     newly-&gt;<a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d" title="父节点">parent</a> = parent;
<a name="l00416"></a>00416 }
<a name="l00417"></a>00417 
<a name="l00425"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaeb412c8138afd90d9d2e271b641c52ac">00425</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaeb412c8138afd90d9d2e271b641c52ac" title="设置当前节点的优先权">treaplnk_set_priority</a>(treaplnk_node* node, 
<a name="l00426"></a>00426                                         <span class="keywordtype">size_t</span> priority)
<a name="l00427"></a>00427 {
<a name="l00428"></a>00428     node-&gt;<a class="code" href="struct____treaplnk__node.html#a12a507bc765598b5db4100af52f045e3" title="优先权">priority</a> = priority;
<a name="l00429"></a>00429 }
<a name="l00430"></a>00430 
<a name="l00438"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga603045fe815f3b650f3086b3747bb6a9">00438</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga603045fe815f3b650f3086b3747bb6a9" title="仅在node不为空时，设置node的父节点">treaplnk_set_parent_if</a>(treaplnk_node* node, 
<a name="l00439"></a>00439                                         treaplnk_node* parent)
<a name="l00440"></a>00440 {
<a name="l00441"></a>00441     <span class="keywordflow">if</span> (node)
<a name="l00442"></a>00442         node-&gt;<a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d" title="父节点">parent</a> = parent;
<a name="l00443"></a>00443 }
<a name="l00444"></a>00444 
<a name="l00450"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae3353c18c25b1b4c315a2407f2499b59">00450</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae3353c18c25b1b4c315a2407f2499b59" title="初始化节点">treaplnk_node_init</a>(treaplnk_node* node)
<a name="l00451"></a>00451 {
<a name="l00452"></a>00452     node-&gt;<a class="code" href="struct____treaplnk__node.html#a36269bd557d652bbb20aba4f5648dc6d" title="父节点">parent</a> = NULL;
<a name="l00453"></a>00453     node-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a> = NULL;
<a name="l00454"></a>00454     node-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a> = NULL;
<a name="l00455"></a>00455     node-&gt;<a class="code" href="struct____treaplnk__node.html#a12a507bc765598b5db4100af52f045e3" title="优先权">priority</a> = 0;
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457 
<a name="l00466"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga10f0160bf916bb920848d908af696f17">00466</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga10f0160bf916bb920848d908af696f17" title="用新节点替换旧节点">treaplnk_iter_replace</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, 
<a name="l00467"></a>00467                     treaplnk_iter victim, treaplnk_iter newly)
<a name="l00468"></a>00468 {
<a name="l00469"></a>00469     treaplnk_iter parent = <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4f501b5392c966d7f7ccb6253ec465" title="得到父节点">treaplnk_parent</a>(victim);
<a name="l00470"></a>00470     
<a name="l00471"></a>00471     <span class="comment">/* 将victim父节点的孩子设为newly */</span>
<a name="l00472"></a>00472     <span class="keywordflow">if</span> (parent) {
<a name="l00473"></a>00473         <span class="keywordflow">if</span> (victim == parent-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a>)
<a name="l00474"></a>00474             parent-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a> = newly;
<a name="l00475"></a>00475         <span class="keywordflow">else</span>
<a name="l00476"></a>00476             parent-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a> = newly;
<a name="l00477"></a>00477     } <span class="keywordflow">else</span>
<a name="l00478"></a>00478         root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a> = newly;
<a name="l00479"></a>00479     
<a name="l00480"></a>00480     <span class="comment">/* 重新确定victim孩子节点的父节点为newly */</span>
<a name="l00481"></a>00481     <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga603045fe815f3b650f3086b3747bb6a9" title="仅在node不为空时，设置node的父节点">treaplnk_set_parent_if</a>(victim-&gt;<a class="code" href="struct____treaplnk__node.html#aaabd7a688dedb620c93809d069cb5906" title="左子节点">left</a>, newly);
<a name="l00482"></a>00482     <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga603045fe815f3b650f3086b3747bb6a9" title="仅在node不为空时，设置node的父节点">treaplnk_set_parent_if</a>(victim-&gt;<a class="code" href="struct____treaplnk__node.html#a1878af8228914890446ad2f0cebcf10c" title="右子节点">right</a>, newly);
<a name="l00483"></a>00483     
<a name="l00484"></a>00484     <span class="comment">/* 替换节点成员 */</span>
<a name="l00485"></a>00485     *newly = *victim;
<a name="l00486"></a>00486 }
<a name="l00487"></a>00487 
<a name="l00494"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaf149eeeee5ce68eab7d07287ecc1f43b">00494</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaf149eeeee5ce68eab7d07287ecc1f43b" title="用新的树根替换旧树根">treaplnk_replace</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* victim, <a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* newly)
<a name="l00495"></a>00495 {
<a name="l00496"></a>00496     newly-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a> = victim-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>;
<a name="l00497"></a>00497 }
<a name="l00498"></a>00498 
<a name="l00505"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4471880ecdda0e76f9f6ca214805a6">00505</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gafd4471880ecdda0e76f9f6ca214805a6" title="交换两个树">treaplnk_swap</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* a, <a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* b)
<a name="l00506"></a>00506 {
<a name="l00507"></a>00507     treaplnk_iter t = a-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>; a-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a> = b-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>; b-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a> = t;
<a name="l00508"></a>00508 }
<a name="l00509"></a>00509 
<a name="l00510"></a>00510 
<a name="l00520"></a>00520 NV_API <span class="keywordtype">int</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4cb4d2e7f6c2518f504eaee046450c4c" title="判断一个节点是否存在于树中">treaplnk_exist</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, treaplnk_iter itr);
<a name="l00521"></a>00521 
<a name="l00530"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga9961c3e28ad5d8bf2e1c599f0f0c0886">00530</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga9961c3e28ad5d8bf2e1c599f0f0c0886" title="得到正向索引对应的节点的迭代器">treaplnk_at</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, <span class="keywordtype">size_t</span> index)
<a name="l00531"></a>00531 {
<a name="l00532"></a>00532     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga71d356704e6ae0fd1b686ac10fce28eb" title="给迭代器增加一段距离或减小一段距离">treaplnk_advance</a>(<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga912adb278fdbb3938e29e0bcf2f58c6e" title="得到树的最左端节点">treaplnk_front</a>(root), index);
<a name="l00533"></a>00533 }
<a name="l00534"></a>00534 
<a name="l00544"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae10f61d50563cd0731692ce8b1ab0cbb">00544</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gae10f61d50563cd0731692ce8b1ab0cbb" title="得到逆向索引对应的节点的迭代器">treaplnk_reverse_at</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, <span class="keywordtype">size_t</span> index)
<a name="l00545"></a>00545 {
<a name="l00546"></a>00546     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga71d356704e6ae0fd1b686ac10fce28eb" title="给迭代器增加一段距离或减小一段距离">treaplnk_advance</a>(<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2215902aa2d70496fccdb14fcf8da0ce" title="得到树的最右端节点">treaplnk_back</a>(root), -(<span class="keywordtype">int</span>)(index));
<a name="l00547"></a>00547 }
<a name="l00548"></a>00548 
<a name="l00556"></a>00556 NV_API treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga912adb278fdbb3938e29e0bcf2f58c6e" title="得到树的最左端节点">treaplnk_front</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root);
<a name="l00557"></a>00557 
<a name="l00565"></a>00565 NV_API treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2215902aa2d70496fccdb14fcf8da0ce" title="得到树的最右端节点">treaplnk_back</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root);
<a name="l00566"></a>00566 
<a name="l00574"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaf5df84d890ae7dc07c210fead0d826ec">00574</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaf5df84d890ae7dc07c210fead0d826ec" title="得到指向正向起始位置的迭代器">treaplnk_begin</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00575"></a>00575 {
<a name="l00576"></a>00576     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga912adb278fdbb3938e29e0bcf2f58c6e" title="得到树的最左端节点">treaplnk_front</a>(root);
<a name="l00577"></a>00577 }
<a name="l00578"></a>00578 
<a name="l00585"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad590259a18b3e07fde596e1cd7dd135f">00585</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad590259a18b3e07fde596e1cd7dd135f" title="得到指向正向终止位置的迭代器">treaplnk_end</a>()
<a name="l00586"></a>00586 {
<a name="l00587"></a>00587     <span class="keywordflow">return</span> NULL;
<a name="l00588"></a>00588 }
<a name="l00589"></a>00589 
<a name="l00597"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12c517e1858f21365e26e5217ccb45af">00597</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12c517e1858f21365e26e5217ccb45af" title="得到当前迭代器的正向终止位置">treaplnk_end_of</a>(treaplnk_iter cur)
<a name="l00598"></a>00598 {
<a name="l00599"></a>00599     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4ef2c4a4f07589b1dae6b47c09ce790a" title="得到当前节点的中序后继节点">treaplnk_next</a>(cur);
<a name="l00600"></a>00600 }
<a name="l00601"></a>00601 
<a name="l00609"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaaf3b3ffd977431ffbe9d7e24ee09e9e9">00609</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaaf3b3ffd977431ffbe9d7e24ee09e9e9" title="得到指向逆向起始位置的迭代器">treaplnk_rbegin</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root)
<a name="l00610"></a>00610 {
<a name="l00611"></a>00611     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2215902aa2d70496fccdb14fcf8da0ce" title="得到树的最右端节点">treaplnk_back</a>(root);
<a name="l00612"></a>00612 }
<a name="l00613"></a>00613 
<a name="l00620"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaab7748cacfeacd6f160350c2f37d89bf">00620</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaab7748cacfeacd6f160350c2f37d89bf" title="得到指向逆向终止位置的迭代器">treaplnk_rend</a>()
<a name="l00621"></a>00621 {
<a name="l00622"></a>00622     <span class="keywordflow">return</span> NULL;
<a name="l00623"></a>00623 }
<a name="l00624"></a>00624 
<a name="l00632"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2a2dcd287fdd62bdd0d9cbbf60caeb60">00632</a> <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2a2dcd287fdd62bdd0d9cbbf60caeb60" title="得到当前迭代器的逆向终止位置">treaplnk_rend_of</a>(treaplnk_iter cur)
<a name="l00633"></a>00633 {
<a name="l00634"></a>00634     <span class="keywordflow">return</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gacdde57d39d567fc2b5dbc661f67bef08" title="得到当前节点的中序前驱节点">treaplnk_prev</a>(cur);
<a name="l00635"></a>00635 }
<a name="l00636"></a>00636 
<a name="l00644"></a>00644 NV_API treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4ef2c4a4f07589b1dae6b47c09ce790a" title="得到当前节点的中序后继节点">treaplnk_next</a>(treaplnk_iter cur);
<a name="l00645"></a>00645 
<a name="l00653"></a>00653 NV_API treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gacdde57d39d567fc2b5dbc661f67bef08" title="得到当前节点的中序前驱节点">treaplnk_prev</a>(treaplnk_iter cur);
<a name="l00654"></a>00654 
<a name="l00662"></a>00662 NV_API treaplnk_iter <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga71d356704e6ae0fd1b686ac10fce28eb" title="给迭代器增加一段距离或减小一段距离">treaplnk_advance</a>(treaplnk_iter cur, <span class="keywordtype">int</span> dist);
<a name="l00663"></a>00663 
<a name="l00674"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gadfbee5eebd305e1c30dcfc00b536dbfb">00674</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gadfbee5eebd305e1c30dcfc00b536dbfb" title="清空树">treaplnk_clear</a>(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, 
<a name="l00675"></a>00675                                 <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga12473c60d17919848883f04bfa09a5a5" title="单参数回调函数指针">treaplnk_pr1</a> erase_handler)
<a name="l00676"></a>00676 {
<a name="l00677"></a>00677     <span class="keywordflow">if</span> (!<a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga96e53af6fe7142244a05e80bce0b3eb0" title="判断树是否为空">treaplnk_empty</a>(root))
<a name="l00678"></a>00678         <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0157ffea5e9b1a9d9bd903d8c6a518d8" title="移除区域内的节点">treaplnk_erases</a>(root, <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga912adb278fdbb3938e29e0bcf2f58c6e" title="得到树的最左端节点">treaplnk_front</a>(root), NULL, erase_handler);
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00681"></a>00681 <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter __treaplnk_inc_later(treaplnk_iter cur, 
<a name="l00682"></a>00682                                             treaplnk_iter* p)
<a name="l00683"></a>00683 {
<a name="l00684"></a>00684     *p = <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga4ef2c4a4f07589b1dae6b47c09ce790a" title="得到当前节点的中序后继节点">treaplnk_next</a>(cur);
<a name="l00685"></a>00685     <span class="keywordflow">return</span> cur;
<a name="l00686"></a>00686 }
<a name="l00687"></a>00687 
<a name="l00688"></a>00688 <span class="keyword">static</span> <span class="keyword">inline</span> treaplnk_iter __treaplnk_dec_later(treaplnk_iter cur, 
<a name="l00689"></a>00689                                             treaplnk_iter* p)
<a name="l00690"></a>00690 {
<a name="l00691"></a>00691     *p = <a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gacdde57d39d567fc2b5dbc661f67bef08" title="得到当前节点的中序前驱节点">treaplnk_prev</a>(cur);
<a name="l00692"></a>00692     <span class="keywordflow">return</span> cur;
<a name="l00693"></a>00693 }
<a name="l00694"></a>00694 
<a name="l00705"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2b8d6bb9789641ed54d971da2f4d7976">00705</a> <span class="preprocessor">#define treaplnk_inc(itr)           ((itr) = treaplnk_next(itr))</span>
<a name="l00706"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga49e38700e1a751927091febf09c6f1dc">00706</a> <span class="preprocessor"></span><span class="preprocessor">#define treaplnk_dec(itr)           ((itr) = treaplnk_prev(itr))</span>
<a name="l00707"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gaa17763173a4fb80564079a86cc9f7eca">00707</a> <span class="preprocessor"></span><span class="preprocessor">#define treaplnk_inc_later(itr) __treaplnk_inc_later(itr, &amp;(itr))</span>
<a name="l00708"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga374159c0572248286e172bd53a90b96c">00708</a> <span class="preprocessor"></span><span class="preprocessor">#define treaplnk_dec_later(itr) __treaplnk_dec_later(itr, &amp;(itr))</span>
<a name="l00709"></a>00709 <span class="preprocessor"></span>
<a name="l00719"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga8837c939518ae0edb8a0dc9325a0692c">00719</a> <span class="preprocessor">#define treaplnk_foreach(_begin, _end, fn, type, member) do {\</span>
<a name="l00720"></a>00720 <span class="preprocessor">        treaplnk_iter _q_e = (_end);                        \</span>
<a name="l00721"></a>00721 <span class="preprocessor">        treaplnk_iter _q_f = (_begin);                      \</span>
<a name="l00722"></a>00722 <span class="preprocessor">        while (_q_f != _q_e) {                              \</span>
<a name="l00723"></a>00723 <span class="preprocessor">            type * _q_t = container_of(_q_f, type, member); \</span>
<a name="l00724"></a>00724 <span class="preprocessor">            treaplnk_inc(_q_f);                             \</span>
<a name="l00725"></a>00725 <span class="preprocessor">            fn(_q_t);                                       \</span>
<a name="l00726"></a>00726 <span class="preprocessor">        }                                                   \</span>
<a name="l00727"></a>00727 <span class="preprocessor">    } while (0)</span>
<a name="l00728"></a>00728 <span class="preprocessor"></span>
<a name="l00738"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga676ec355adc879995dfcaa2d08ef9b53">00738</a> <span class="preprocessor">#define treaplnk_reverse_foreach(_rbegin, _rend, fn, type, member) do {\</span>
<a name="l00739"></a>00739 <span class="preprocessor">        treaplnk_iter _q_e = (_rend);                       \</span>
<a name="l00740"></a>00740 <span class="preprocessor">        treaplnk_iter _q_f = (_rbegin);                     \</span>
<a name="l00741"></a>00741 <span class="preprocessor">        while (_q_f != _q_e) {                              \</span>
<a name="l00742"></a>00742 <span class="preprocessor">            type * _q_t = container_of(_q_f, type, member); \</span>
<a name="l00743"></a>00743 <span class="preprocessor">            treaplnk_dec(_q_f);                             \</span>
<a name="l00744"></a>00744 <span class="preprocessor">            fn(_q_t);                                       \</span>
<a name="l00745"></a>00745 <span class="preprocessor">        }                                                   \</span>
<a name="l00746"></a>00746 <span class="preprocessor">    } while (0)</span>
<a name="l00747"></a>00747 <span class="preprocessor"></span>
<a name="l00748"></a>00748 NV_API <span class="keywordtype">void</span> __do_treaplnk_recurse_foreach(treaplnk_iter cur, 
<a name="l00749"></a>00749                                 <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset);
<a name="l00750"></a>00750 
<a name="l00751"></a>00751 NV_API <span class="keywordtype">void</span> __do_treaplnk_recurse_reverse_foreach(
<a name="l00752"></a>00752                     treaplnk_iter cur, <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset);
<a name="l00753"></a>00753 
<a name="l00754"></a>00754 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __treaplnk_recurse_foreach(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, 
<a name="l00755"></a>00755                                 <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset)
<a name="l00756"></a>00756 {
<a name="l00757"></a>00757     <span class="keywordflow">if</span> (fn)
<a name="l00758"></a>00758         __do_treaplnk_recurse_foreach(root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>, fn, offset);
<a name="l00759"></a>00759 }
<a name="l00760"></a>00760 
<a name="l00761"></a>00761 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __treaplnk_recurse_reverse_foreach(
<a name="l00762"></a>00762     <a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset)
<a name="l00763"></a>00763 {
<a name="l00764"></a>00764     <span class="keywordflow">if</span> (fn)
<a name="l00765"></a>00765         __do_treaplnk_recurse_reverse_foreach(root-&gt;<a class="code" href="structtreaplnk__root.html#a0c7711a1496b39126279c2b9285a24ed" title="根节点">node</a>, fn, offset);
<a name="l00766"></a>00766 }
<a name="l00767"></a>00767 
<a name="l00776"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga8f36380b2f733d0e16a5e99b3058c6e6">00776</a> <span class="preprocessor">#define TREAPLNK_RECURSE_PROC(name, type, param) void name(type * param)</span>
<a name="l00777"></a>00777 <span class="preprocessor"></span>
<a name="l00801"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2e08d0567b5bebd37192d2997c05f7a6">00801</a> <span class="preprocessor">#define treaplnk_recurse_foreach(root, fn, type, member) \</span>
<a name="l00802"></a>00802 <span class="preprocessor">    __treaplnk_recurse_foreach(root, (void (*)(void*))(fn), \</span>
<a name="l00803"></a>00803 <span class="preprocessor">            offset_of(type, member))</span>
<a name="l00804"></a>00804 <span class="preprocessor"></span>
<a name="l00814"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga2954703560aba06e10390cecd55ce874">00814</a> <span class="preprocessor">#define treaplnk_recurse_reverse_foreach(root, fn, type, member) \</span>
<a name="l00815"></a>00815 <span class="preprocessor">    __treaplnk_recurse_reverse_foreach(root, (void (*)(void*))(fn), \</span>
<a name="l00816"></a>00816 <span class="preprocessor">            offset_of(type, member))</span>
<a name="l00817"></a>00817 <span class="preprocessor"></span>
<a name="l00846"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gace2efa644b7ebd855208b023d9e298d1">00846</a> <span class="preprocessor">#define treaplnk_search(root, newly, greater, res, type, member) do {\</span>
<a name="l00847"></a>00847 <span class="preprocessor">        treaplnk_root* _k_r = (root);                           \</span>
<a name="l00848"></a>00848 <span class="preprocessor">        type * _k_pn = (newly);                                 \</span>
<a name="l00849"></a>00849 <span class="preprocessor">        treaplnk_iter _k_p = _k_r-&gt;node;                        \</span>
<a name="l00850"></a>00850 <span class="preprocessor">        (res) = NULL;                                           \</span>
<a name="l00851"></a>00851 <span class="preprocessor">        while (_k_p) {                                          \</span>
<a name="l00852"></a>00852 <span class="preprocessor">            type * _k_pr = container_of(_k_p, type, member);    \</span>
<a name="l00853"></a>00853 <span class="preprocessor">            if (greater(_k_pr, _k_pn))                          \</span>
<a name="l00854"></a>00854 <span class="preprocessor">                _k_p = _k_p-&gt;left;                              \</span>
<a name="l00855"></a>00855 <span class="preprocessor">            else if (greater(_k_pn, _k_pr))                     \</span>
<a name="l00856"></a>00856 <span class="preprocessor">                _k_p = _k_p-&gt;right;                             \</span>
<a name="l00857"></a>00857 <span class="preprocessor">            else {                                              \</span>
<a name="l00858"></a>00858 <span class="preprocessor">                (res) = _k_p; break;                            \</span>
<a name="l00859"></a>00859 <span class="preprocessor">            }                                                   \</span>
<a name="l00860"></a>00860 <span class="preprocessor">        }                                                       \</span>
<a name="l00861"></a>00861 <span class="preprocessor">    } while (0)</span>
<a name="l00862"></a>00862 <span class="preprocessor"></span>
<a name="l00891"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga0596a3dbc9f19ed80f25ed406590539a">00891</a> <span class="preprocessor">#define treaplnk_insert(root, newly, greater, res, type, member) do {\</span>
<a name="l00892"></a>00892 <span class="preprocessor">        treaplnk_root* _k_r = (root);                                   \</span>
<a name="l00893"></a>00893 <span class="preprocessor">        treaplnk_iter* _k_pp = &amp;_k_r-&gt;node;                             \</span>
<a name="l00894"></a>00894 <span class="preprocessor">        treaplnk_iter _k_n = (newly);                                   \</span>
<a name="l00895"></a>00895 <span class="preprocessor">        treaplnk_iter _k_p;                                             \</span>
<a name="l00896"></a>00896 <span class="preprocessor">        type * _k_pn = container_of(_k_n, type, member);                \</span>
<a name="l00897"></a>00897 <span class="preprocessor">        (res) = 1;                                                      \</span>
<a name="l00898"></a>00898 <span class="preprocessor">        treaplnk_node_init(_k_n);                                       \</span>
<a name="l00899"></a>00899 <span class="preprocessor">        while (*_k_pp) {                                                \</span>
<a name="l00900"></a>00900 <span class="preprocessor">            type * _k_pr = container_of(_k_p = *_k_pp, type, member);   \</span>
<a name="l00901"></a>00901 <span class="preprocessor">            if (greater(_k_pr, _k_pn))                                  \</span>
<a name="l00902"></a>00902 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;left;                                    \</span>
<a name="l00903"></a>00903 <span class="preprocessor">            else if (greater(_k_pn, _k_pr))                             \</span>
<a name="l00904"></a>00904 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;right;                                   \</span>
<a name="l00905"></a>00905 <span class="preprocessor">            else {                                                      \</span>
<a name="l00906"></a>00906 <span class="preprocessor">                (res) = 0; break;                                       \</span>
<a name="l00907"></a>00907 <span class="preprocessor">            }                                                           \</span>
<a name="l00908"></a>00908 <span class="preprocessor">        }                                                               \</span>
<a name="l00909"></a>00909 <span class="preprocessor">        if (res) {                                                      \</span>
<a name="l00910"></a>00910 <span class="preprocessor">            treaplnk_link(_k_n, _k_p, _k_pp);                           \</span>
<a name="l00911"></a>00911 <span class="preprocessor">            treaplnk_fix(_k_r, _k_n, _k_p);                             \</span>
<a name="l00912"></a>00912 <span class="preprocessor">        }                                                               \</span>
<a name="l00913"></a>00913 <span class="preprocessor">    } while (0)</span>
<a name="l00914"></a>00914 <span class="preprocessor"></span>
<a name="l00915"></a>00915 NV_API <span class="keywordtype">void</span> __treaplnk_serialize(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, 
<a name="l00916"></a>00916                                 <span class="keywordtype">void</span>** buf, <span class="keywordtype">size_t</span> offset);
<a name="l00917"></a>00917 
<a name="l00918"></a>00918 NV_API <span class="keywordtype">void</span> __treaplnk_deserialize(<a class="code" href="structtreaplnk__root.html" title="树根">treaplnk_root</a>* root, <span class="keywordtype">char</span>** buf, 
<a name="l00919"></a>00919                                  <span class="keywordtype">size_t</span> cnt, <span class="keywordtype">size_t</span> offset);
<a name="l00920"></a>00920 
<a name="l00930"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#gad43d55a99cb69cce140b881eac510614">00930</a> <span class="preprocessor">#define treaplnk_serialize(root, buf, type, member) \</span>
<a name="l00931"></a>00931 <span class="preprocessor">    __treaplnk_serialize(root, (void**)(buf), offset_of(type, member))</span>
<a name="l00932"></a>00932 <span class="preprocessor"></span>
<a name="l00943"></a><a class="code" href="group___xE6_xA0_x91_xE5_xA0_x86.html#ga69bc92914978fa2ad835fe250bbaad8c">00943</a> <span class="preprocessor">#define treaplnk_deserialize(root, buf, cnt, type, member) \</span>
<a name="l00944"></a>00944 <span class="preprocessor">    __treaplnk_deserialize(root, (char**)(buf), cnt, offset_of(type, member))</span>
<a name="l00945"></a>00945 <span class="preprocessor"></span>
<a name="l00948"></a>00948 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00949"></a>00949 <span class="preprocessor"></span>}
<a name="l00950"></a>00950 <span class="preprocessor">#endif  </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00951"></a>00951 
<a name="l00952"></a>00952 <span class="preprocessor">#endif  </span><span class="comment">/* #ifndef __NV_TREAPLNK__ */</span>
<a name="l00953"></a>00953 
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>数据结构</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2015年七月16日 星期四 12:00:37 for Navo Portable Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
